package main

import "fmt"

type myint int

type Book struct {
	title string
	auth string
}

func changebook1(book Book) {
	book.title = "666"
}

func changebook2(book *Book) {
	book.title = "777"
}

type Hero struct {
	Name string
	Ad int
	Level int
}

func (this *Hero) Show() {
	fmt.Println(this.Name)
}
func (this *Hero) GetName() string {
	return this.Name
}
func (this *Hero) SetName(newName string)  {
	this.Name = newName
}

type superMan struct {
	Hero
	Speed int
}

type AnimalIF interface {
	Sleep()
	GetColor() string
}

type Cat struct {
	color string

}

func (this *Cat) Sleep() {
	fmt.Println("cat is sleep")
}

func (this *Cat) GetColor() string{
	return this.color
}

func showAnimal(animal AnimalIF) {
	animal.Sleep()
	fmt.Println(animal.GetColor())
}

func main() {
	var a myint = 10
	fmt.Println(a)

	var book1 Book
	book1.title = "lizhiqiang"
	fmt.Println(book1)

	changebook1(book1)
	fmt.Println(book1)
	changebook2(&book1)
	fmt.Println(book1)

	hero := Hero{Name: "zangsan", Ad:100, Level:1}
	hero.Show()
	hero.SetName("li4")
	hero.Show()

	s := superMan{Hero{"aa", 2, 1}, 88}
	s.Show()

	var dd superMan
	dd.Name = "haha"
	dd.Show()

	var animal AnimalIF
	animal = &Cat{"Green"}
	animal.Sleep()

	cat1 := Cat{"Green"}
	dog1 := Cat{"red"}

	showAnimal(&cat1)
	showAnimal(&dog1)
}

